﻿<UserControl x:Class="TimeBarPlugin.InternalState"
			 x:ClassModifier="internal"
			 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             
             xmlns:Converters="clr-namespace:Utils.Wpf.Converters;assembly=Utils"
             xmlns:System="clr-namespace:System;assembly=mscorlib" 
			 xmlns:TP="clr-namespace:TimeBarPlugin"
			 
             Background="#1F1F1F"
             
             mc:Ignorable="d"
             
             d:DesignHeight="130" 
             d:DataContext="{d:DesignInstance Type=TP:InternalStateVM}" >

	<UserControl.Resources>
		<ResourceDictionary>
			<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="States">
				<ObjectDataProvider.MethodParameters>
					<x:Type TypeName="TP:DecisionEngineState" />
				</ObjectDataProvider.MethodParameters>
			</ObjectDataProvider>
			<Converters:MultiplierConverter x:Key="MultiplierConverter" />
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="pack://application:,,,/Plugins;component/PluginTheme.xaml" />
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<!-- Title -->
		<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="8" Text="Internal State" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="Header" Margin="6" />
		
		<!-- Values -->
		<UniformGrid Grid.Row="1" Grid.Column="1" Columns="3" Height="{Binding ActualHeight, ElementName=HeightReference}" >
			<Button Command="{Binding LoadStateCommand}" >
				<Image Source="Resources\Open.ico" Stretch="None" />
				<Button.ToolTip>
					<StackPanel>
						<TextBlock Foreground="Black" FontWeight="Bold" Text="Load Plugin State" />
						<TextBlock Foreground="Black" Text="Loads the last saved plugin state into the engine." />
					</StackPanel>
				</Button.ToolTip>
			</Button>
			<Button Command="{Binding SaveStateCommand}" >
				<Image Source="Resources\Save.ico" Stretch="None" />
				<Button.ToolTip>
					<StackPanel>
						<TextBlock Foreground="Black" FontWeight="Bold" Text="Save Plugin State" />
						<TextBlock Foreground="Black" Text="Saves the current plugin state to be able to recover it latter." />
					</StackPanel>
				</Button.ToolTip>
			</Button>
			<Button Command="{Binding ResetStateCommand}" >
				<Image Source="Resources\Reset.ico" Stretch="None" />
				<Button.ToolTip>
					<StackPanel>
						<TextBlock Foreground="Black" FontWeight="Bold" Text="Clears Plugin State" />
						<TextBlock Foreground="Black" Text="Returns the plugin state to its initial values." />
					</StackPanel>
				</Button.ToolTip>
			</Button>
		</UniformGrid>
		
		<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="3,3,6,3" Text="State" x:Name="ReferenceElement" />
		<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="3,3,6,3" Text="Previous State" />
		<TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="3,3,6,3" Text="Current Day" />

		<ComboBox  Grid.Row="2" Grid.Column="1" Margin="0,1,0,1" ItemsSource="{Binding Source={StaticResource States}}" SelectedItem="{Binding State, Mode=TwoWay}"  Width="{Binding ActualWidth, ElementName=ReferenceElement, Converter={StaticResource MultiplierConverter}, ConverterParameter=1.4}" x:Name="HeightReference" >
			<ComboBox.Resources>
				<Style TargetType="TextBlock">
					<Style.Triggers>
						<Trigger Property="IsEnabled" Value="True">
							<Setter Property="Foreground" Value="Black" />
						</Trigger>
					</Style.Triggers>
				</Style>
			</ComboBox.Resources>
		</ComboBox>
		<ComboBox  Grid.Row="3" Grid.Column="1" Margin="0,1,0,0" ItemsSource="{Binding Source={StaticResource States}}" SelectedItem="{Binding PreviousState, Mode=TwoWay}"  Width="{Binding ActualWidth, ElementName=ReferenceElement, Converter={StaticResource MultiplierConverter}, ConverterParameter=1.4}" Height="{Binding ActualHeight, ElementName=HeightReference}" >
			<ComboBox.Resources>
				<Style TargetType="TextBlock">
					<Style.Triggers>
						<Trigger Property="IsEnabled" Value="True">
							<Setter Property="Foreground" Value="Black" />
						</Trigger>
					</Style.Triggers>
				</Style>
			</ComboBox.Resources>
		</ComboBox>
		<DatePicker Grid.Row="4" Grid.Column="1" IsTodayHighlighted="True" VerticalAlignment="Center" Background="Transparent" FirstDayOfWeek="Monday" SelectedDate="{Binding ProcessedDay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True}" BorderThickness="0" Width="{Binding ActualWidth, ElementName=ReferenceElement, Converter={StaticResource MultiplierConverter}, ConverterParameter=1.4}" />
	
		<!-- Separator -->
		<Border Grid.Row="1" Grid.Column="2" Grid.RowSpan="4" BorderBrush="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />
		
		<!-- Values -->
		<TextBlock Grid.Row="1" Grid.Column="3" VerticalAlignment="Center" Margin="3,3,6,3" Text="Start value" />
		<TextBlock Grid.Row="2" Grid.Column="3" VerticalAlignment="Center" Margin="3,3,6,3" Text="Stop Loss" />
		<TextBlock Grid.Row="3" Grid.Column="3" VerticalAlignment="Center" Margin="3,3,6,3" Text="High Threshold" />
		<TextBlock Grid.Row="4" Grid.Column="3" VerticalAlignment="Center" Margin="3,3,6,3" Text="Low Threshold" />

		<TextBox Grid.Row="1" Grid.Column="4" Margin="0,1,0,1" Text="{Binding Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, StringFormat=0.##, Path=StartValue}" Width="{Binding ActualWidth, ElementName=ReferenceElement, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.85}" />
		<TextBox Grid.Row="2" Grid.Column="4" Margin="0,1,0,1" Text="{Binding Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, StringFormat=0.##, Path=StopLoss}" />
		<TextBox Grid.Row="3" Grid.Column="4" Margin="0,1,0,1" Text="{Binding Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, StringFormat=0.##, Path=HighThreshold}" />
		<TextBox Grid.Row="4" Grid.Column="4" Margin="0,1,0,1" Text="{Binding Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, StringFormat=0.##, Path=LowThreshold}" />

		<!-- Separator -->
		<Border Grid.Row="1" Grid.Column="5" Grid.RowSpan="4" BorderBrush="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

		<!-- Values -->
		<TextBox Grid.Row="1" Grid.Column="6" Margin="0,1,0,1" Text="{Binding Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, Path=CurrentVolume}" Width="{Binding ActualWidth, ElementName=ReferenceElement, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.85}" />
		<TextBox Grid.Row="2" Grid.Column="6" Margin="1" Text="{Binding UpdateSourceTrigger=PropertyChanged, Path=LastData, Mode=OneWay, StringFormat=hh\\:mm\\:ss}" Style="{StaticResource TextBoxReadonly}" Width="{Binding ActualWidth, ElementName=ReferenceElement, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.85}" />
		<TextBox Grid.Row="3" Grid.Column="6" Margin="1" Text="{Binding UpdateSourceTrigger=PropertyChanged, Path=AskValue, Mode=OneWay}" Style="{StaticResource TextBoxReadonly}" Width="{Binding ActualWidth, ElementName=ReferenceElement, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.85}" />
		<TextBox Grid.Row="4" Grid.Column="6" Margin="1" Text="{Binding UpdateSourceTrigger=PropertyChanged, Path=BidValue, Mode=OneWay}" Style="{StaticResource TextBoxReadonly}" Width="{Binding ActualWidth, ElementName=ReferenceElement, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.85}" />
	
		<TextBlock Grid.Row="1" Grid.Column="7" VerticalAlignment="Center" Margin="6,3,3,3" Text="Volume" />
		<TextBlock Grid.Row="2" Grid.Column="8" VerticalAlignment="Center" Margin="6,3,3,3" Text="Last Data" />
		<TextBlock Grid.Row="3" Grid.Column="7" VerticalAlignment="Center" Margin="6,3,3,3" Text="Ask" />
		<TextBlock Grid.Row="4" Grid.Column="7" VerticalAlignment="Center" Margin="6,3,3,3" Text="Bid" />


	</Grid>
</UserControl>
